{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>会议列表</legend>
    </fieldset>
    <blockquote class="layui-elem-quote">
        <a href="{:url('meetingAdd')}" class="layui-btn layui-btn-sm">添加会议</a>
        <div class="layui-inline" style="float: right">
            <form class="layui-form" action="">
                <div class="layui-form-item" style="margin-bottom: 0px">

                    <div class="layui-inline" style="margin-right: 0px">

                        <div class="layui-input-inline" style="width: 200px;">
                            <input type="text" id="keyword" name="keyword" autocomplete="off"
                                   placeholder="请输入会议名称"
                                   class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline" style="margin-right: 0px">
                        <div class="layui-btn-group layui-inline" style="margin: 0px">
                            <!--此重置 仅仅是个跳转链接-->
                            <a  href="{:url('lists')}" class="layui-btn layui-btn-primary">重置</a>
                            <button id="search" class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="formDemo" style="background-color: #009688;">
                                <i class="layui-icon">&#xe615;</i>查找
                            </button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </blockquote>

    <table class="layui-table" id="list" lay-filter="list"></table>
</div>

<script type="text/html" id="status">
    {{#  if(d.status == 0){ }}
    待进行
    {{# }else if(d.status == 1){ }}
    进行中
    {{# }else if(d.status == 2){ }}
    已结束
    {{# }else if(d.status == -1){ }}
    已取消
    {{#  } }}
</script>
<script type="text/html" id="barDemo">

    {{#  if(d.status == 0){ }}
    <a href="{:url('meetingEdit')}?id={{d.id}}" class="layui-btn layui-btn-xs">{:lang('edit')}</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="cancel">取消会议</a>
    {{# }else{ }}
    <a href="javascript;" class="layui-btn layui-btn-xs layui-btn-disabled">{:lang('edit')}</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs  layui-btn-disabled" lay-event="cancel">取消会议</a>
    {{#  } }}
</script>

{include file="common/foot"/}
<script>
    layui.use('table', function() {
        var table = layui.table, $ = layui.jquery;var form = layui.form;
        var tableIn = table.render({
            id: 'user',
            elem: '#list',
            url: "{:url('lists')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {field: 'name',title: '会议名称', width: 130},
                {field: 'address', title: '会议地址', width: 100},
                {field: 'creater', title: '创建人', width: 100},
                {field: 'status', title: '会议状态', width: 100, templet: '#status'},
                {field: 'create_time',title: '创建时间', width: 120},
                {width: 160, align: 'center', toolbar: '#barDemo'}
            ]],
            limit: 10 //每页默认显示的数量
        });
        $('#search').on('click', function () {

            var keyword = $('#keyword').val();
            console.log(keyword);
            if ($.trim(keyword) === '') {
                layer.msg('{:lang("pleaseEnter")}查找信息！', {icon: 0});
                return;
            }
            //表格重载
            tableIn.reload({
                //传递额外参数
                where: {keyword: keyword}

            });
        });
        table.on('tool(list)', function(obj){
            var data = obj.data;
            if(obj.event === 'cancel'){
                layer.confirm('你确定要取消吗？', function(index){
                    $.post("{:url('cancel')}",{meeting_id:data.id},function(res){
                        if(res.code==1){
                            layer.msg(res.msg,{time:1000,icon:1});
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });
    });
</script>
</body>
</html>